const fs = require("fs");
const path = require("path");

//生成从minNum到maxNum的随机数
function randomNum(minNum, maxNum) {
  switch (arguments.length) {
    case 1:
      return parseInt(Math.random() * minNum + 1, 10);
      break;
    case 2:
      return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10);
      break;
    default:
      return 0;
      break;
  }
}
function main() {
  let list = [];
  const minNum = 13;
  const maxNum = 260;
  let time = 0;
  for (let index = 0; index < 1000; index++) {
    let user = `user${index}`;
    // 生成 60 个 48~106 之间的数据
    if (index < 60) {
      time = randomNum(48, 100);
    }
    // 生成 940 个 100~260 之间的数据
    else {
      if (index < 60 + 350) {
        // 前350 100 ~ 150
        time = randomNum(106, 150);
      } else if (index < 60 + 350 + 400) {
        // 中间400 150 ~ 210
        time = randomNum(150, 210);
      } else {
        // 剩下 210~260
        time = randomNum(210, 260);
      }
    }
    list.push(`${time}`);
  }
  fs.writeFileSync(
    path.join(__dirname, "购买行为记录-time.txt"),
    list.join("\n")
  );
}

main();
